/**
 * 晨会评论表
 */
var Waterline = require('waterline');
var uuid = require('node-uuid');
var moment = require('moment');

/**
 * @type {void|*}
 */
module.exports = Waterline.Collection.extend({
    identity: 'comment',
    tableName: 'tb_comment',
    connection: "mysql",
    attributes: {

        rowId: {
            type: 'string',
            primaryKey: true,
            unique: true,
            required: true,
            uuidv4: true,
            columnName: 'rowid',
            defaultsTo: function () {
                return uuid.v4();
            }
        },
        createUid: {
            type: 'string',
            required: true,
            columnName: 'createuid',
            model: 'user'
        },
        enable:{
            type:'string',
            required:true,
            columnName:'enable'
        },
        name:{
            type:'string',
            required: true,
            columnName:'name'
        },
        type:{
            type:'string',
            required: true,
            columnName:'type'
        },
        mconference:{
            type: 'string',
            columnName: 'mconference',
            model:"mconference"
        },
        context: {
            type: 'string',
            columnName: 'context'
        },
        toJSON: function () {
            var obj = this.toObject();
            obj.createdAt = moment(obj.createdAt).format('YYYY-MM-DD HH:mm');
            obj.updatedAt = moment(obj.updatedAt).format('YYYY-MM-DD HH:mm');
            return obj;
        }

    }
});
